<% layout('/layouts/default.html', {title: '通关缴税管理', libs: ['validate','fileupload','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(taxClearance.isNewRecord ? '新增通关缴税' : '编辑通关缴税')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${taxClearance}" action="${ctx}/financial/taxclearance/taxClearance/save" method="post" class="form-horizontal">
		<div class="box-body">
			<div class="form-unit">${text('基本信息')}</div>
			<#form:hidden path="taxClearanceId"/>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('编号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="taxClearanceCode" maxlength="100" class="form-control" placeholder="自动生成" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('车架号')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="frameNumber" items="${frameNumberList}" onchange="frameNumberChange()"
							itemLabel="frameNumber" itemValue="frameNumber" blankOption="true" class="form-control required"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('服务订单')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="serviceOrderCode" class="form-control" readonly="true"/>
							<#form:hidden path="serviceOrderId"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('车辆')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="carName" class="form-control" readonly="true"/>
							<#form:hidden path="carId"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('版型')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="areaName" dictType="car_quyu" blankOption="true" class="form-control" readonly="true"/>
							<#form:hidden path="area"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('报关行')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customsBrokerName" class="form-control" readonly="true"/>
							<#form:hidden path="customsBroker"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('客户')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customerName" class="form-control" readonly="true"/>
							<#form:hidden path="customerId"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('国内资方')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="investorId" items="${gnzfList}" itemLabel="supplierName" itemValue="supplierId"
							class="form-control required" blankOption="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('是否资方垫付')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="isinvpad" dictType="sys_yes_no" blankOption="true" class="form-control required"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('垫付方')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<!--<#form:select path="prepaidId" items="${gnzfList}" itemLabel="supplierName" itemValue="supplierId"
                            class="form-control" blankOption="true"/>-->
							<#form:treeselect id="company" title="${text('公司选择')}"
							path="company.companyCode" labelPath="company.companyName"
							url="${ctx}/sys/company/treeData"
							btnClass="" class="" allowClear="true" canSelectRoot="true" canSelectParent="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
							<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('状态')}</h4>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('状态')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="status1" dictType="tax_clearance_status" blankOption="true" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('税金信息')}</h4>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('申报价格')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="declaredPrice" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('出税价格')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="taxPrice" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('差额')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="difference" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('海关综合税率')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customsCombinedTaxRate" maxlength="10" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('综合税金')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="comprehensiveTax" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('垫税信息-缴税信息')}</h4>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('外币价格')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="foreignCurrencyPrice" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('海关汇率')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customsExchangeRate" maxlength="10" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('币种')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="currencyName" dictType="sys_bizhong" blankOption="true" class="form-control" readonly="true"/>
							<#form:hidden path="currency"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('缴税方式')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="taxPaymentMethod" dictType="tax_payment_method" class="form-control required"
							blankOption="true" onchange="taxPaymentMethodChange()"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('缴税截止日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="taxPaymentDeadline" readonly="true" maxlength="20" class="form-control"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required">*</span> ${text('资方垫税方案')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="padTaxMode" itemLabel="name" itemValue="id"
							class="form-control required" blankOption="true" onchange="padTaxModeChange()"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('出税日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="taxDate" readonly="true" maxlength="20" class="form-control"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required ">*</span> ${text('缴税日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="taxPaymentDate" readonly="true" maxlength="20" class="form-control laydate required"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd" data-done="padTaxModeChange()"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('代垫金额')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="prepaidAmount" class="form-control number" />
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('代收代付金额')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="amount" class="form-control number"/>
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
							<span class="required hide">*</span> ${text('垫税说明')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<#form:textarea path="padTaxMemo" rows="4" maxlength="255" class="form-control"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('垫税信息-资方')}</h4>
			<div class="ml10 mr10">
				<table id="taxClearanceDetailDataGrid1"></table>
				<!--						<% if (hasPermi('financial:taxclearance:taxClearance:edit')){ %>-->
				<!--						<a href="#" id="taxClearanceDetailDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> ${text('增行')}</a>-->
				<!--						<% } %>-->
			</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2" title="">
							<span class="required hide">*</span> ${text('延期说明')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-10">
							<#form:textarea path="delayMemo" rows="4" maxlength="255" class="form-control"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('垫税信息-客户')}</h4>
			<div class="ml10 mr10">
				<table id="taxClearanceDetailDataGrid2"></table>
				<!--					<% if (hasPermi('financial:taxclearance:taxClearance:edit')){ %>-->
				<!--					<a href="#" id="taxClearanceDetailDataGridAddRowBtn2" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> ${text('增行')}</a>-->
				<!--					<% } %>-->
			</div>
			<h4 class="form-unit">${text('还税日期-资方')}</h4>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('实际还款日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="investorActualRepaymentDate" readonly="true" maxlength="20" class="form-control"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('实际天数')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="investorActualDays" class="form-control digits" readonly="true"/>
						</div>
					</div>
				</div>
				<!--					<div class="col-xs-6">-->
				<!--						<div class="form-group">-->
				<!--							<label class="control-label col-sm-4" title="">-->
				<!--								<span class="required hide">*</span> ${text('付款实时利息')}：<i class="fa icon-question hide"></i></label>-->
				<!--							<div class="col-sm-8">-->
				<!--								<#form:input path="investorRealTimeInterest" class="form-control number" readonly="true"/>-->
				<!--							</div>-->
				<!--						</div>-->
				<!--					</div>-->
				<!--					<div class="col-xs-6">-->
				<!--						<div class="form-group">-->
				<!--							<label class="control-label col-sm-4" title="">-->
				<!--								<span class="required hide">*</span> ${text('付款实际利息')}：<i class="fa icon-question hide"></i></label>-->
				<!--							<div class="col-sm-8">-->
				<!--								<#form:input path="investorActualInterest" class="form-control number" readonly="true"/>-->
				<!--							</div>-->
				<!--						</div>-->
				<!--					</div>-->
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('垫税利息')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="investorPadTaxInterest" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('垫税延期利息')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="investorPadTaxYqInterest" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('预付单')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="prepaymentId"  items="${listPrepayment}" itemLabel="prepaymentCode"
							itemValue="prepaymentId" blankOption="true" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('还税应付单')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="apId"  items="${listAp}" itemLabel="apCode"
							itemValue="apId" blankOption="true" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('还税日期-客户')}</h4>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('实际还款日期')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customerActualRepaymentDate" readonly="true" maxlength="20" class="form-control"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('实际天数')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customerActualDays" class="form-control digits" readonly="true"/>
						</div>
					</div>
				</div>
				<!--					<div class="col-xs-6">-->
				<!--						<div class="form-group">-->
				<!--							<label class="control-label col-sm-4" title="">-->
				<!--								<span class="required hide">*</span> ${text('收款实时利息')}：<i class="fa icon-question hide"></i></label>-->
				<!--							<div class="col-sm-8">-->
				<!--								<#form:input path="customerRealTimeInterest" class="form-control number" readonly="true"/>-->
				<!--							</div>-->
				<!--						</div>-->
				<!--					</div>-->
				<!--					<div class="col-xs-6">-->
				<!--						<div class="form-group">-->
				<!--							<label class="control-label col-sm-4" title="">-->
				<!--								<span class="required hide">*</span> ${text('收款实际利息')}：<i class="fa icon-question hide"></i></label>-->
				<!--							<div class="col-sm-8">-->
				<!--								<#form:input path="customerActualInterest" class="form-control number" readonly="true"/>-->
				<!--							</div>-->
				<!--						</div>-->
				<!--					</div>-->
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('垫税利息')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customerPadTaxInterest" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('垫税延期利息')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="customerPadTaxYqInterest" class="form-control number" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('预收单')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="advancesReceivedId"  items="${listAdvancesReceived}" itemLabel="advancesReceivedCode"
							itemValue="advancesReceivedId" blankOption="true" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('还税应收单')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:select path="arId"  items="${listAr}" itemLabel="arCode"
							itemValue="arId" blankOption="true" class="form-control " readonly="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2">
							<span class="required hide">*</span> ${text('图片上传')}：</label>
						<div class="col-sm-10">
							<#form:fileupload id="uploadImage" bizKey="${taxClearance.id}" bizType="taxClearance_image"
							uploadType="image" class="" readonly="false" preview="true"/>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2">
							<span class="required hide">*</span> ${text('附件上传')}：</label>
						<div class="col-sm-10">
							<#form:fileupload id="uploadFile" bizKey="${taxClearance.id}" bizType="taxClearance_file"
							uploadType="all" class="" readonly="false" preview="true"/>
						</div>
					</div>
				</div>
			</div>
			<h4 class="form-unit">${text('系统信息')}</h4>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('创建者')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="createBy" maxlength="64" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('创建时间')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="createDate" readonly="true" maxlength="20" class="form-control "
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('更新者')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="updateBy" maxlength="64" class="form-control" readonly="true"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title="">
							<span class="required hide">*</span> ${text('更新时间')}：<i class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							<#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
							dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="box-footer">
			<div class="row">
				<div class="col-sm-offset-2 col-sm-10">
					<% if (hasPermi('financial:taxclearance:taxClearance:edit')){ %>
					<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
					<% } %>
					<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
				</div>
			</div>
		</div>
	</#form:form>
</div>
</div>
<% } %>
<script>
	//初始化通关缴税明细DataGrid对象  垫税信息-资方
	$("#taxClearanceDetailDataGrid1").dataGrid({
		data: ${toJson(taxClearance.taxClearanceDetailList1)},
		datatype: "local", // 设置本地数据
		autoGridHeight: function(){return 'auto'}, // 设置自动高度

		// 设置数据表格列
		columnModel: [
			{header:'状态', name:'status', editable:true, hidden:true},
			{header:'类型', name:'type', editable:true, hidden:true},
			{header:'主键', name:'taxClearanceDetailId', editable:true, hidden:true},
			{header:'${text("开始天数")}', name:'startDays', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control digits','readonly':'true'}},
			{header:'${text("结束天数")}', name:'endDays', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control digits','readonly':'true'}},
			{header:'${text("开始日期")}', name:'startDate', width:150,
				formatter:'date', formatoptions:{srcformat:'Y-m-d H:i:s',newformat:'Y-m-d'},
				editable:true, edittype:'text', editoptions:{'class':'form-control', 'readonly':'true',
					dataInit: function(element){
						laydate.render({elem:element, type:'date', format:'yyyy-MM-dd'});
					}
				}
			},
			{header:'${text("结束日期")}', name:'endDate', width:150,
				formatter:'date', formatoptions:{srcformat:'Y-m-d H:i:s',newformat:'Y-m-d'},
				editable:true, edittype:'text', editoptions:{'class':'form-control', 'readonly':'true',
					dataInit: function(element){
						laydate.render({elem:element, type:'date', format:'yyyy-MM-dd'});
					}
				}
			},
			{header:'${text("保证金比例")}', name:'marginRatio', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number','readonly':'true'}},
			{header:'${text("保证金金额")}', name:'marginAmount', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number','readonly':'true'}},
			{header:'${text("利率")}', name:'interestRate', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control','readonly':'true'}},
			{header:'${text("利息")}', name:'interest', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number','readonly':'true'}},
			{header:'${text("备注")}', name:'remark', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'255', 'class':'form-control','readonly':'true'}},
			{header:'${text("通关缴税ID")}', name:'taxClearanceId.taxClearanceId', editable:true, hidden:true},
			// {header:'${text("操作")}', name:'actions', width:80, sortable:false, fixed:true, formatter: function(val, obj, row, act){
			// 	var actions = [];
			// 	if (val == 'new'){
			// 		actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#taxClearanceDetailDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			// 	}else{
			// 		actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#taxClearanceDetailDataGrid\').dataGrid(\'setRowData\',\''+obj.rowId+'\',null,{display:\'none\'});$(\'#'+obj.rowId+'_status\').val(\''+Global.STATUS_DELETE+'\');});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			// 	}
			// 	return actions.join('');
			// }, editoptions: {defaultValue: 'new'}}
		],

		// 编辑表格参数
		editGrid: true,				// 是否是编辑表格
		editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
		editGridAddRowInitData: {taxClearanceDetailId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据

		// 编辑表格的提交数据参数
		editGridInputFormListName: 'taxClearanceDetailList1', // 提交的数据列表名
		editGridInputFormListAttrs: 'status,taxClearanceDetailId,startDays,endDays,startDate,endDate,marginAmount,interestRate,interest,remark,type,taxClearanceId.taxClearanceId,', // 提交数据列表的属性字段

		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});

	//初始化通关缴税明细DataGrid对象  垫税信息-客户
	$("#taxClearanceDetailDataGrid2").dataGrid({
		data: ${toJson(taxClearance.taxClearanceDetailList2)},
		datatype: "local", // 设置本地数据
		autoGridHeight: function(){return 'auto'}, // 设置自动高度

		// 设置数据表格列
		columnModel: [
			{header:'状态', name:'status', editable:true, hidden:true},
			{header:'类型', name:'type', editable:true, hidden:true},
			{header:'主键', name:'taxClearanceDetailId', editable:true, hidden:true},
			{header:'${text("开始天数")}', name:'startDays', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control digits','readonly':'true'}},
			{header:'${text("结束天数")}', name:'endDays', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control digits','readonly':'true'}},
			{header:'${text("开始日期")}', name:'startDate', width:150,
				formatter:'date', formatoptions:{srcformat:'Y-m-d H:i:s',newformat:'Y-m-d'},
				editable:true, edittype:'text', editoptions:{'class':'form-control', 'readonly':'true',
					/*dataInit: function(element){
						laydate.render({elem:element, type:'date', format:'yyyy-MM-dd'});
					}*/
				}
			},
			{header:'${text("结束日期")}', name:'endDate', width:150,
				formatter:'date', formatoptions:{srcformat:'Y-m-d H:i:s',newformat:'Y-m-d'},
				editable:true, edittype:'text', editoptions:{'class':'form-control', 'readonly':'true',
					/*dataInit: function(element){
						laydate.render({elem:element, type:'date', format:'yyyy-MM-dd'});
					}*/
				}
			},
			{header:'${text("保证金比例")}', name:'marginRatio', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number','readonly':'true'}},
			{header:'${text("保证金金额")}', name:'marginAmount', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number','readonly':'true'}},
			{header:'${text("利率")}', name:'interestRate', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control','readonly':'true'}},
			{header:'${text("利息")}', name:'interest', width:150, editable:true, edittype:'text', editoptions:{'class':'form-control number','readonly':'true'}},
			{header:'${text("备注")}', name:'remark', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'255', 'class':'form-control','readonly':'true'}},
			{header:'${text("通关缴税ID")}', name:'taxClearanceId.taxClearanceId', editable:true, hidden:true},
			// {header:'${text("操作")}', name:'actions', width:80, sortable:false, fixed:true, formatter: function(val, obj, row, act){
			// 		var actions = [];
			// 		if (val == 'new'){
			// 			actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#taxClearanceDetailDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			// 		}else{
			// 			actions.push('<a href="#" onclick="js.confirm(\'${text("你确认要删除这条数据吗？")}\', function(){$(\'#taxClearanceDetailDataGrid\').dataGrid(\'setRowData\',\''+obj.rowId+'\',null,{display:\'none\'});$(\'#'+obj.rowId+'_status\').val(\''+Global.STATUS_DELETE+'\');});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
			// 		}
			// 		return actions.join('');
			// 	}, editoptions: {defaultValue: 'new'}}
		],

		// 编辑表格参数
		editGrid: true,				// 是否是编辑表格
		editGridInitRowNum: 0,		// 编辑表格的初始化新增行数
		editGridAddRowInitData: {taxClearanceDetailId: '', status: Global.STATUS_NORMAL},	// 新增行的时候初始化的数据

		// 编辑表格的提交数据参数
		editGridInputFormListName: 'taxClearanceDetailList2', // 提交的数据列表名
		editGridInputFormListAttrs: 'status,taxClearanceDetailId,startDays,endDays,startDate,endDate,marginAmount,interestRate,interest,remark,type,taxClearanceId.taxClearanceId,', // 提交数据列表的属性字段

		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});
</script>
<script>
	$("#inputForm").validate({
		submitHandler: function(form){
			js.ajaxSubmitForm($(form), function(data){
				js.showMessage(data.message);
				if(data.result == Global.TRUE){
					js.closeCurrentTabPage(function(contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
		}
	});
	frameNumberChange();
	function frameNumberChange() {
		// js.log("$(#frameNumbe).val()="+$("#frameNumber").val());
		if ($("#frameNumber").val() != ""&& $("#frameNumber").val() != null) {
			$.ajax({
				type: "POST",
				url: "${ctx}/financial/taxclearance/taxClearance/getCarInfo",
				data: {"frameNumber": $("#frameNumber").val()},
				success: function (data) {
					$("#carName").val(data.tcar.carName);
					$("#carId").val(data.carId);
					$("#areaName").val(data.tcar.area).trigger('change');
					$("#area").val(data.tcar.area);
					$("#declaredPrice").attr("value", data.declaredPrice);
					$("#taxPrice").attr("value", data.taxPriceF);
					$("#customsCombinedTaxRate").attr("value", data.customsCombinedTaxRate);
					$("#comprehensiveTax").attr("value", data.comprehensiveTax);
					$("#difference").attr("value", $("#declaredPrice").val() - $("#taxPrice").val());
					$("#foreignCurrencyPrice").attr("value", data.foreignCurrencyPrice);
					$("#customsExchangeRate").attr("value", data.customsExchangeRate);
				}
			});
			$.ajax({
				type: "POST",
				url: "${ctx}/financial/taxclearance/taxClearance/getServiceOrderInfo",
				data: {"frameNumber": $("#frameNumber").val()},
				success: function (data) {
					$("#serviceOrderId").val(data.serviceOrderId);
					$("#serviceOrderCode").val(data.serviceOrderCode);
					$("#customerId").val(data.customer.customerId);
					$("#customerName").val(data.customer.customerName);
					// $("#serviceOrderId").val(data.serviceOrderId).trigger('change');
					// $("#customerId").val(data.customer.customerId).trigger('change');
					$("#investorId").val(data.investorId).trigger('change');
					$("#currencyName").val(data.currency).trigger('change');
					$("#currency").val(data.currency);
				}
			});
			$.ajax({
				type: "POST",
				url: "${ctx}/financial/taxclearance/taxClearance/getCustomsDeclarationInfo",
				data: {"frameNumber": $("#frameNumber").val()},
				success: function (data) {
					$("#customsBroker").val(data.customsBroker);
					$("#customsBrokerName").val(data.brolerSupplier.supplierName);
					$("#taxPaymentMethod").val(data.taxPaymentMethod).trigger('change');
					$("#taxPaymentDeadline").attr("value", data.taxDeadlineDate);
					$("#taxDate").attr("value", data.taxDate);
				}
			});
		} else {
			$("#carName").val("");
			$("#carId").val("");
			$("#areaName").val("").trigger('change');
			$("#area").val("");
			$("#declaredPrice").attr("value", "");
			$("#taxPrice").attr("value", "");
			$("#customsCombinedTaxRate").attr("value", "");
			$("#comprehensiveTax").attr("value", "");
			$("#difference").attr("value", "");
			$("#foreignCurrencyPrice").attr("value", "");
			$("#customsExchangeRate").attr("value", "");
			$("#serviceOrderId").val("");
			$("#serviceOrderCode").val("");
			$("#customerId").val("");
			$("#customerName").val("");
			$("#investorId").val("").trigger('change');
			$("#currencyName").val("").trigger('change');
			$("#currency").val("");
			$("#customsBroker").val("");
			$("#customsBrokerName").val("");
			$("#taxPaymentMethod").val("").trigger('change');
			$("#taxPaymentDeadline").attr("value", "");
			$("#taxDate").attr("value", "");
		}
	}
	// taxPaymentMethodChange();
	function taxPaymentMethodChange(){
		// js.log("taxPaymentMethod="+$("#taxPaymentMethod").val());
		if($("#taxPaymentMethod").val() != "1" && $("#taxPaymentMethod").val() != null && $("#taxPaymentMethod").val() != ""){
			$.ajax({
				type : "post",
				async : false,
				url : "${ctx}/financial/taxclearance/taxClearance/getList",
				data : {
					'supplierId' : $("#investorId").val(),
					'taxPaymentMethod' : $("#taxPaymentMethod").val()
				},
				dataType : "json",
				success : function(msg) {
					$("#padTaxMode").empty();
					if (msg.length > 0) {
						for (let i = 0; i < msg.length; i++) {
							let partId = msg[i].investorFinancialInfoId;
							let partName = msg[i].groupName;
							let option = $("<option>").attr({"value" : partId}).text(partName);
							$("#padTaxMode").append(option);
						}
						let option = $("<option>").attr({"value" : ""}).text("");
						$("#padTaxMode option:first").prop("selected", 'selected');
						$("#padTaxMode").change();
					}
				},
				error : function(json) {
					$.jBox.alert("网络异常！");
				}
			});
		}

	}

	function padTaxModeChange() {
		// 资方垫税方案   缴税方式   缴税日期
		if ($("#padTaxMode").val() != "" && $("#taxPaymentMethod").val() != "1" && $("#taxPaymentMethod").val() != "" && $("#taxPaymentDate").val() != "") {
			$.ajax({
				type: "POST",
				url: "${ctx}/financial/taxclearance/taxClearance/getDetailList",
				async:true,
				data: {
					"id": $("#padTaxMode").val()
				},
				success: function (data) {
					alert("data:"+data);
					// 资方
					let ids1 = $('#taxClearanceDetailDataGrid1').dataGrid('getDataIDs');
					for (let i = 0; i < ids1.length ; i++) {
						$('#taxClearanceDetailDataGrid1').dataGrid('delRowData', ids1[i]);
					}
					for(let i=0; i<data.padTaxInterestList1.length; i++){
						if(data.padTaxInterestList1[i].stageType == "1"){
							var taxPaymentDate = $("#taxPaymentDate").val();
							var startDays = data.padTaxInterestList1[i].startDays;
							var startDaysAdd = js.addDate(js.parseDate(taxPaymentDate), startDays);
							var endDays = data.padTaxInterestList1[i].endDays;
							var endDaysAdd = js.addDate(js.parseDate(taxPaymentDate), endDays);

							$("#taxClearanceDetailDataGrid1").jqGrid("addRow", {
								position: "last",
								addRowParams: {keys: false, focusField: true},
								initdata: {id: "",
									startDays: data.padTaxInterestList1[i].startDays,
									endDays: data.padTaxInterestList1[i].endDays,
									startDate: js.formatDate(startDaysAdd, 'yyyy-MM-dd'),
									endDate:  js.formatDate(endDaysAdd, 'yyyy-MM-dd'),
									marginRatio:data.padTaxInterestList1[i].investorMarginRatio,
									marginAmount: Number(data.padTaxInterestList1[i].investorMarginRatio) * Number($("#prepaidAmount").val()) / 100 ,
									interestRate:  data.padTaxInterestList1[i].investorInterestRatio,
									type:1,
								}
							});
						}
					}
					// 客户
					let ids2 = $('#taxClearanceDetailDataGrid2').dataGrid('getDataIDs');
					for (let i = 0; i < ids2.length ; i++) {
						$('#taxClearanceDetailDataGrid2').dataGrid('delRowData', ids2[i]);
					}
					for(let i=0; i<data.padTaxInterestList1.length; i++){
						if(data.padTaxInterestList1[i].stageType == "2"){
							$("#taxClearanceDetailDataGrid2").jqGrid("addRow", {
								position: "last",
								addRowParams: {keys: false, focusField: true},
								initdata: {id: "",
									startDays: data.padTaxInterestList1[i].startDays,
									endDays: data.padTaxInterestList1[i].endDays,
									startDate: js.formatDate(js.addDate(js.parseDate($("#taxPaymentDate").val()), data.padTaxInterestList1[i].startDays), 'yyyy-MM-dd'),
									endDate:  js.formatDate(js.addDate(js.parseDate($("#taxPaymentDate").val()), data.padTaxInterestList1[i].endDays), 'yyyy-MM-dd'),
									marginRatio: data.padTaxInterestList1[i].customerMarginRatio,
									marginAmount: Number(data.padTaxInterestList1[i].customerMarginRatio) * Number($("#prepaidAmount").val()) / 100,
									interestRate:  data.padTaxInterestList1[i].customerInterestRatio,
									type:2,
								}
							});
						}
					}
					if (typeof window.webuploaderRefresh == 'function'){
						window.webuploaderRefresh();
					}
				}
			});
		} else {
		}
	}

	$("#prepaidAmount").change(function () {
		padTaxModeChange();
		let taxPaymentMethod = $("#taxPaymentMethod").val();
		if(taxPaymentMethod != "2") {
			// 资方
			let zfIds = $('#taxClearanceDetailDataGrid1').dataGrid('getDataIDs');
			for (let i = 0; i < zfIds.length ; i++) {
				$('#taxClearanceDetailDataGrid1').dataGrid('saveRow', zfIds[i], true);
				let ratio = $("#taxClearanceDetailDataGrid1").jqGrid("getCell", zfIds[i], "marginRatio");
				$("#taxClearanceDetailDataGrid1").jqGrid('setCell', zfIds[i], "marginAmount", Number(ratio)*Number($(this).val())*Number(0.01));
				let marginAmount = $("#taxClearanceDetailDataGrid1").jqGrid("getCell", zfIds[i], "marginAmount");
				let interestRate = $("#taxClearanceDetailDataGrid1").jqGrid("getCell", zfIds[i], "interestRate");
				if(interestRate){
					$("#taxClearanceDetailDataGrid1").jqGrid('setCell', zfIds[i], "interest", Number(marginAmount)* Number(interestRate)*Number(0.01));
				}
				$('#taxClearanceDetailDataGrid1').dataGrid('editRow', zfIds[i]);
			}
			// 客户
			let khIds = $('#taxClearanceDetailDataGrid2').dataGrid('getDataIDs');
			for (let i = 0; i < khIds.length; i++) {
				$('#taxClearanceDetailDataGrid2').dataGrid('saveRow', khIds[i], true);
				//保证金比例
				let ratio = $("#taxClearanceDetailDataGrid2").jqGrid("getCell", khIds[i], "marginRatio");
				$("#taxClearanceDetailDataGrid2").jqGrid('setCell', khIds[i], "marginAmount", Number(ratio) * Number($(this).val())*Number(0.01));
				//保证金额度
				let marginAmount = $("#taxClearanceDetailDataGrid2").jqGrid("getCell", khIds[i], "marginAmount");
				let interestRate = $("#taxClearanceDetailDataGrid2").jqGrid("getCell", khIds[i], "interestRate");
				if(interestRate){
					$("#taxClearanceDetailDataGrid2").jqGrid('setCell', khIds[i], "interest", Number(marginAmount)* Number(interestRate)*Number(0.01));
				}
				$('#taxClearanceDetailDataGrid2').dataGrid('editRow', khIds[i]);
			}
		}else{
			// 资方
			let zfIds = $('#taxClearanceDetailDataGrid1').dataGrid('getDataIDs');
			for (let i = 0; i < zfIds.length; i++) {
				$('#taxClearanceDetailDataGrid1').dataGrid('saveRow', zfIds[i], true);
				let ratio = $("#taxClearanceDetailDataGrid1").jqGrid("getCell", zfIds[i], "marginRatio");
				$("#taxClearanceDetailDataGrid1").jqGrid('setCell', zfIds[i], "marginAmount", Number(ratio)*Number($(this).val())*Number(0.01));
				$('#taxClearanceDetailDataGrid1').dataGrid('editRow', zfIds[i]);
			}
			// 客户
			let khIds = $('#taxClearanceDetailDataGrid2').dataGrid('getDataIDs');
			for (let i = 0; i < khIds.length; i++) {
				$('#taxClearanceDetailDataGrid2').dataGrid('saveRow', khIds[i], true);
				let ratio = $("#taxClearanceDetailDataGrid2").jqGrid("getCell", khIds[i], "marginRatio");
				$("#taxClearanceDetailDataGrid2").jqGrid('setCell', khIds[i], "marginAmount", Number(ratio)*Number($(this).val())*Number(0.01));
				$('#taxClearanceDetailDataGrid2').dataGrid('editRow', khIds[i]);
			}

			//关税利息
			$.ajax({
				type: "POST",
				url: "${ctx}/financial/taxclearance/taxClearance/getInterestList",
				async:true,
				data: {
					"groupId": $("#padTaxMode").val(),
					"taxPaymentDate": $("#taxPaymentDate").val()
				},
				success: function (data) {
					console.info(data);
					// 资方
					let zfIds = $('#taxClearanceDetailDataGrid1').dataGrid('getDataIDs');
					for (let i = 0; i < zfIds.length; i++) {
						$('#taxClearanceDetailDataGrid1').dataGrid('saveRow', zfIds[i], true);
						let ratio = $("#taxClearanceDetailDataGrid1").jqGrid("getCell", zfIds[i], "marginRatio");
						//$("#taxClearanceDetailDataGrid1").jqGrid('setCell', zfIds[i], "marginAmount", Number(ratio)*Number($(this).val())*Number(0.01));
						let interest  = data.padTaxInterestList[i].customerInterestAmount;
						let containFlag = data.padTaxInterestList[i].containFlag;
						if(containFlag == "1") {
							$("#taxClearanceDetailDataGrid1").jqGrid('setCell', zfIds[i], "interest", interest);
						}else{
							$("#taxClearanceDetailDataGrid1").jqGrid('setCell', zfIds[i], "interest", 0);
						}
						$('#taxClearanceDetailDataGrid1').dataGrid('editRow', zfIds[i]);
					}
					// 客户
					let khIds = $('#taxClearanceDetailDataGrid2').dataGrid('getDataIDs');
					for (let i = 0; i < khIds.length; i++) {
						$('#taxClearanceDetailDataGrid2').dataGrid('saveRow', khIds[i], true);
						let ratio = $("#taxClearanceDetailDataGrid2").jqGrid("getCell", khIds[i], "marginRatio");
						//$("#taxClearanceDetailDataGrid2").jqGrid('setCell', khIds[i], "marginAmount", Number(ratio)*Number($(this).val())*Number(0.01));
						let interest  = data.padTaxInterestList[i].customerInterestAmount;
						let containFlag = data.padTaxInterestList[i].containFlag;
						if(containFlag == "1") {
							$("#taxClearanceDetailDataGrid2").jqGrid('setCell', khIds[i], "interest", interest);
						}else{
							$("#taxClearanceDetailDataGrid2").jqGrid('setCell', khIds[i], "interest", 0);
						}
						$('#taxClearanceDetailDataGrid2').dataGrid('editRow', khIds[i]);
					}
				}
			});
		}
	});
</script>
